home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1995 Todd Thomas
-
- /************************************************************************
- CLASS: MiscGraphNode
- INHERITS FROM: Object
- PROGRAMMER: Todd Thomas (todd@avocado.supernet.ab.ca)
- BEGAN: June 6, 1994
- LAST CHANGED: September 14, 1994
- VERSION: 0.5
-
- This class represents a node in a directed graph. Each node contains a list
- of children, parents, and an announcer (for node dependancies). The state
- of the children's list determines if it is a leaf or not. If the method
- -children returns nil, then you are a leaf. A children's list of count zero
- is still a non-leaf node (it just happens to have no children right now).
- The default is to be a leaf node. To change that, either use setLeaf: NO
- or add some children to the node.
-
- Each object takes care of it's own garbage collection by freeing itself when
- it no longer has any parents or users. The list of parents is kept only for
- garbage collection and easy traversal of the graph in both directions.
-
- This class is responsible for the basics of adding/removing children,
- parents, users and listeners, along with it's own garbage collection.
- Anything more complicated should be a subclass. (See MiscFile)
-
- Anyone familiar with Scott Roy's IconKit will recognize many of the methods
- this class uses. Since so much of the content (interface and protocols) of
- this object comes from the IconKit, I would definitely suggest you take a
- look at it. It can be found on cs.orst.edu in /pub/next/sources/objects.
-
- For more information on the announcer object, see it's documentation.
-
- This object is included in the MiscKit by permission from the author
- and its use is governed by the MiscKit license, found in the file
- "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- for a list of all applicable permissions and restrictions.
-
- *************************************************************************/
-
- #import <misckit/MiscDependency.h>
- #import <objc/Object.h>
-
- @class List;
- @class MiscAnnouncer;
-
-
- @interface MiscGraphNode: Object <MiscDependency>
- {
- List *children; // list of node's children
- List *parents; // list of node's parents (strictly for gc)
- MiscAnnouncer *announcer; // announcer object
- }
-
- + initialize;
- - init;
- - free;
-
- - (BOOL)isLeaf;
- - setLeaf: (BOOL)isALeaf;
-
- - announce: (SEL)announcement;
-
- // methods for child maniplulation
-
- - children;
- - addChild: aChild;
- - addChildren: theChildren;
- - removeChild: aChild;
- - removeChildren: theChildren;
-
- // methods for parent manipulation
-
- - parents;
- - addParent: aParent;
- - removeParent: aParent;
-
- // methods for garbage collection
-
- - checkForFree;
- - (BOOL)garbageCollect;
-
- // methods for keeping track of dependancies between nodes and other objects
- // these are from the IKDependency protocol
-
- - addUser: aUser;
- - removeUser: aUser;
- - addListener: aListener;
- - removeListener: aListener;
-
- // Archiving
-
- - awake;
- - read: (NXTypedStream *)stream;
- - write: (NXTypedStream *)stream;
-
- @end
-
-
- // These notifications will be sent to any users and/or listeners that
- // are registered with the MiscGraphNode's announcer.
-
- @interface Object (MiscGraphNodeNotification)
-
- - didAddChild: sender;
- - didAddChildren: sender;
- - didAddParent: sender;
- - didRemoveChild: sender;
- - didRemoveChildren: sender;
- - didRemoveParent: sender;
- - willFree: sender;
-
- @end
-
-